<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cetak Fee</title>
<?php $this->load->helper('HTML');
echo link_tag('css/style2.css');
echo link_tag('images/favicon.ico','shortcut icon','image/x-icon');
?>
</head>
<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=fee_sc.xls");
header("Pragma: no-cache");
header("Expires: 0");
?>
<body>
<table width="800" align="center" class="detail">
	<tr class="detail2">
   	  <td align="center">
        <table width="800" align="center" class="detail">
        <tr class="detail2">
          <td width="440" rowspan="4" valign="top"><img src="<?php echo base_url();?>images/logo.jpg" />&nbsp;</td>
          <td width="41"><a href="javascript:window.print()" onclick="location.href='laporan/fee';"><img src="<?php echo base_url();?>/images/print.jpg"/></a></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td width="41">&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td colspan="2" align="center">LAPORAN FEE <?php echo $nama_cabang?></td>
                <td>&nbsp;</td>
        </tr>
        <tr >
            <td colspan="2"class="detail2" align="center">PERIODE : <?php echo strtoupper($nama_bulan). " " . date('Y') ?></td>
                <td>&nbsp;</td>
        </tr>
    </table>    </td>
    <tr>
    	<td align="center"><table width="800" border="1" align="center"  class="detail">
          <tr class="detail2">
            <th width="50" rowspan="3">NAMA</th>
            <th width="60" rowspan="3">STATUS</th>
            <th width="37" rowspan="3">DIST</th>
            <th width="88" rowspan="3">KET</th>
          </tr>
          <tr class="detail2">
            <td colspan="2">&nbsp;</td>
            <th rowspan="2">HARGA NETTO</th>
            <th width="87" rowspan="2">HARGA <br />
              DEALER</th>
            <th width="29" rowspan="2">FEE</th>
            <th width="53" rowspan="2">PPH 5%</th>
            <th width="71" rowspan="2">JUMLAH</th>
          </tr>
          <tr>
            <th >GROUP 20%</th>
            <th >GROUP 10%</th>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <?php
				$regD = 0;
				$hutD = 0;
				$har_hut = 0;
				$har_reg = 0;
				$reg_total = 0;
				$hut_total = 0;
								
				$omsetreg20=0;
				$omsetreg10=0;
				$omsetdealerreg=0;
				foreach ($Reg as $row):
						if($row->TGroup20 < 0){
							$temp2 = 0;
						}else{
							$temp2 = $row->TGroup20;
						}
						if($row->TGroup10 < 0){
							$temp1 = 0;
						}else{
							$temp1 = $row->TGroup10;
						}
					     $omsetreg20= $omsetreg20 + $temp2;
						 $omsetreg10= $omsetreg10 + $temp1;
				endforeach;	
				foreach ($RegDealer as $row1):
						if($row1->RegDealer < 0){
							$temp3 = 0;
						}else{
							$temp3 = $row1->RegDealer;
						}
							
					     $omsetdealerreg= $omsetdealerreg + $temp3;
				endforeach;	 
				?>
          <tr>
            <td><?php echo $data_cabang->strkepala_cabang?></td>
            <td><?php echo 'PIMPINAN';?></td>
            <td><?php echo $data_cabang->strnama_cabang?></td>
            <td>Reguler</td>
            <td align="center"><?php echo (empty($omsetreg20))?'0':number_format($omsetreg20)?></td>
            <td align="center"><?php echo (empty($omsetreg10))?'0':number_format($omsetreg10)?></td>
            <td align="center">0</td>
            <td align="center"><?php $hdealer = ($omsetreg20 - ($omsetreg20*0.2)) + ($omsetreg10 - ($omsetreg10*0.1));
			echo (empty($hdealer))?'0':number_format($hdealer)?></td>
            <td align="center"><?php echo (empty($hdealer))?'0':number_format(($hdealer) * 5/100)?></td>
            <td align="center"><?php echo (empty($hdealer))?'0':number_format(($hdealer * 5/100) * 5/100)?></td>
            <td align="center"><?php 
					
					if(!empty($hdealer)){
						$regD = $hdealer;
						$har_reg =  (($hdealer) * 5/100) - (($hdealer* 5/100) * 5/100);
					
						echo (empty($har_reg))?'0':number_format($har_reg);
					}
					
					?></td>
          </tr>
          <?php 
				$omsethut20=0;
				$omsethut10=0;
				$omsetdealerhut=0;
				foreach ($Hut as $row2):
					     if($row2->TGroup20 < 0){
							$temp2 = 0;
						}else{
							$temp2 = $row2->TGroup20;
						}
						if($row2->TGroup10 < 0){
							$temp1 = 0;
						}else{
							$temp1 = $row2->TGroup10 ;
						}
					    $omsethut20= $omsethut20 + $temp2;
						 $omsethut10= $omsethut10 + $temp1;
				endforeach;	
				foreach ($HutDealer as $row3):
					     if($row3->HutDealer < 0){
							$temp3 = 0;
						}else{
							$temp3 = $row3->HutDealer;
						}
						$omsetdealerhut= $omsetdealerhut + $temp3;
				endforeach;	 
				?>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>Chall Hut</td>
            <td align="center"><?php echo (empty($omsethut20))?'0':number_format($omsethut20)?></td>
            <td align="center"><?php echo (empty($omsethut10))?'0':number_format($omsethut10)?></td>
            <td align="center">0</td>
            <td align="center"><?php $hdealerhut = ($omsethut20 - ($omsethut20*0.2)) + ($omsethut10 - ($omsethut10*0.1));
					echo (empty($hdealerhut))?'0':number_format($hdealerhut)?></td>
            <td align="center"><?php echo (empty($hdealerhut))?'0':number_format(($hdealerhut) * 5/100); $fhut=($hdealerhut * 5)/100?></td>
            <td align="center"><?php echo (empty($hdealerhut))?'0':number_format(($fhut*5)/100);?></td>
            <td align="center"><?php 
					
					if(!empty($hdealerhut)){
						$hutD = $hdealerhut;
						$har_hut = (($hdealerhut) * 5/100) - (($hdealerhut* 5/100) * 5/100);
						echo (empty($har_hut))?'0':number_format($har_hut);
					}
					?></td>
          </tr>
          <?php 
				$omsettulipcal20=0;
				$omsettulipcal10=0;
				$omsetdealercal=0;
				foreach ($Cal as $row4):
					      if($row4->TGroup20 < 0){
							$temp2 = 0;
						}else{
							$temp2 = $row4->TGroup20;
						}
						if($row4->TGroup10 < 0){
							$temp1 = 0;
						}else{
							$temp1 = $row4->TGroup10;
						}
					   $omsettulipcal20= $omsettulipcal20 + $temp2;
						 $omsettulipcal10= $omsettulipcal10 + $temp1;

				endforeach;	
				foreach ($CalDealer as $row5):
					      if($row5->CalDealer < 0){
							$temp3 = 0;
						}else{
							$temp3 = $row5->CalDealer;
						}
						$omsetdealercal= $omsetdealercal + $temp3;
				endforeach;	 
				?>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>Challenge</td>
            <td align="center"><?php echo (empty($omsettulipcal20))?'0':number_format($omsettulipcal20)?></td>
            <td align="center"><?php echo (empty($omsettulipcal10))?'0':number_format($omsettulipcal10)?></td>
            <td align="center">0</td>
            <td align="center"><?php $hdealercal = ($omsettulipcal20 - ($omsettulipcal20*0.2)) + ($omsettulipcal10 - ($omsettulipcal10*0.1));
					echo (empty($hdealercal))?'0':number_format($hdealercal)?></td>
            <td align="center"><?php echo (empty($hdealercal))?'0':number_format(($hdealercal) * 5/100)?></td>
            <td align="center"><?php echo (empty($hdealercal))?'0':number_format(($hdealercal * 5/100)*5/100)?></td>
            <td align="center"><?php 
					$calD=0;
					$har_cal=0;
					if(!empty($hdealercal)){
						$calD = $hdealercal;
						$har_cal = (($hdealercal) * 5/100) - (($hdealercal* 5/100) * 5/100);
						echo (empty($har_cal))?'0':number_format($har_cal);
					}
					?></td>
          </tr>
          <?php 
		  	//tgl 14 agustus 2013 pengubahan dengan menambahkan Total_Omset untuk menghitung data yang valid dan menampilkan nya dipenjualan omset10. mengganti TGroup10 dengan Total_Omset
				$omsettin20=0;
				$omsettin10=0;
				$omsetdealertin=0;
				foreach ($tin as $row6):
				
					     $omsettin20= $omsettin20 + $row6->TGroup20;
						 //$omsettin10= $omsettin10 + $row6->TGroup10;
						 $omsettin10= $omsettin10 + $row6->Total_Omset;
						 
				endforeach;	
				foreach ($tinDealer as $row7):
					     $omsetdealertin= $omsetdealertin + $row7->tinDealer;
				endforeach;	 
				?>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>Trade In</td>
            <td align="center"><?php echo (empty($omsettin20))?'0':number_format($omsettin20)?></td>
            <td align="center"><?php echo (empty($omsettin10))?'0':number_format($omsettin10)?></td>
            <td align="center">0</td>
            <td align="center"><?php $hdealertin = ($omsettin20 - ($omsettin20*0.2)) + ($omsettin10 - ($omsettin10*0.1));
					echo (empty($hdealertin))?'0':number_format($hdealertin)?></td>
            <td align="center"><?php echo (empty($hdealertin))?'0':number_format(($hdealertin) * 5/100)?></td>
            <td align="center"><?php echo (empty($hdealertin))?'0':number_format(($hdealertin * 5/100)*5/100)?></td>
            <td align="center"><?php 
					$tinD=0;
					$har_tin=0;
					if(!empty($hdealertin)){
						$tinD = $hdealertin;
						$har_tin = (($hdealertin) * 5/100) - (($hdealertin* 5/100) * 5/100);
						echo (empty($har_tin))?'0':number_format($har_tin);
					}
					?></td>
          </tr>
          <?php 
				$omsetifi=0;
				$omsetdealerifi=0;
				foreach ($ifi as $row8):
					     $omsetifi= $omsetifi + $row8->inttotal_omset;
				endforeach;	
				foreach ($ifiDealer as $row9):
					     $omsetdealerifi= $omsetdealerifi + $row9->ifiDealer;
				endforeach;	 
				?>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>1 Free 1 Hut/Nett</td>
            <td align="center">0</td>
            <td align="center">0</td>
            <td align="center"><?php echo (empty($omsetifi))?'0':number_format($omsetifi)?></td>
            <td align="center"><?php echo (empty($omsetdealerifi))?'0':number_format($omsetdealerifi)?></td>
            <td align="center"><?php echo (empty($omsetdealerifi))?'0':number_format(($omsetdealerifi) * 5/100)?></td>
            <td align="center"><?php echo (empty($omsetdealerifi))?'0':number_format(($omsetdealerifi * 5/100)*5/100)?></td>
            <td align="center"><?php 
					$ifiD=0;
					$har_ifi=0;
					if(!empty($omsetdealerifi)){
						$ifiD = $omsetdealerifi;
						$har_ifi = (($omsetdealerifi) * 5/100) - (($omsetdealerifi* 5/100) * 5/100);
						echo (empty($har_ifi))?'0':number_format($har_ifi);
					}
					?></td>
          </tr>
          <?php 
				$omsetifo10=0;
				$omsetdealerifo=0;
				foreach ($ifo as $row10):
					     $omsetifo10= $omsetifo10 + $row10->TGroup10;
				endforeach;	
				foreach ($ifoDealer as $row11):
					     $omsetdealerifo= $omsetdealerifo + $row11->ifoDealer;
				endforeach;	 
				?>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>1 Free 1 10%</td>
            <td align="center">0</td>
            <td align="center"><?php echo (empty($omsetifo10))?'0':number_format($omsetifo10)?></td>
            <td align="center">0</td>
            <td align="center"><?php $hdealerifo = ($omsetifo10 - ($omsetifo10*0.1));
					echo (empty($hdealerifo))?'0':number_format($hdealerifo)?></td>
            <td align="center"><?php echo (empty($hdealerifo))?'0':number_format(($hdealerifo) * 5/100)?></td>
            <td align="center"><?php echo (empty($hdealerifo))?'0':number_format(($hdealerifo * 5/100)*5/100)?></td>
            <td align="center"><?php 
					$ifoD=0;
					$har_ifo=0;
					if(!empty($hdealerifo)){
						$ifoD = $hdealerifo;
						$har_ifo = (($hdealerifo) * 5/100) - (($hdealerifo* 5/100) * 5/100);
						echo (empty($har_ifo))?'0':number_format($har_ifo);
					}
					?></td>
          </tr>
          <?php 
				$omsetnet=0;
				$omsetdealernet=0;
				foreach ($net as $row12):
					     $omsetnet= $omsetnet + $row12->inttotal_omset;
				endforeach;	
				foreach ($netDealer as $row13):
					     $omsetdealernet= $omsetdealernet + $row13->netDealer;
				endforeach;	 
				?>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>Netto</td>
            <td align="center">0</td>
            <td align="center">0</td>
            <td align="center"><?php echo (empty($omsetnet))?'0':number_format($omsetnet)?></td>
            <td align="center"><?php echo (empty($omsetdealernet))?'0':number_format($omsetdealernet)?></td>
            <td align="center"><?php echo (empty($omsetdealernet))?'0':number_format(($omsetdealernet) * 5/100)?></td>
            <td align="center"><?php echo (empty($omsetdealernet))?'0':number_format(($omsetdealernet * 5/100)*5/100)?></td>
            <td align="center"><?php 
					$netD=0;
					$har_net=0;
					if(!empty($omsetdealernet)){
						$netD = $omsetdealernet;
						$har_net = (($omsetdealernet) * 5/100) - (($omsetdealernet* 5/100) * 5/100);
						echo (empty($har_net))?'0':number_format($har_net);
					}
					?></td>
          </tr>
          <?php 
				$omsetsp=0;
				$omsetdealersp=0;
				foreach ($sp as $row14):
					     $omsetsp= $omsetsp + $row14->inttotal_omset;
				endforeach;	
				foreach ($spDealer as $row15):
					     $omsetdealersp= $omsetdealersp + $row15->netDealer;
				endforeach;	 
				?>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>Special Price</td>
            <td align="center">0</td>
            <td align="center">0</td>
            <td align="center"><?php echo (empty($omsetsp))?'0':number_format($omsetsp)?></td>
            <td align="center"><?php echo (empty($omsetdealersp))?'0':number_format($omsetdealersp)?></td>
            <td align="center"><?php echo (empty($omsetdealersp))?'0':number_format(($omsetdealersp) * 5/100)?></td>
            <td align="center"><?php echo (empty($omsetdealersp))?'0':number_format(($omsetdealersp * 5/100)*5/100)?></td>
            <td align="center"><?php 
					$spD=0;
					$har_sp=0;
					if(!empty($omsetdealersp)){
						$spD = $omsetdealersp;
						$har_sp = (($omsetdealersp) * 5/100) - (($omsetdealersp* 5/100) * 5/100);
						echo (empty($har_sp))?'0':number_format($har_sp);
					}
					?></td>
          </tr>
          <?php 
				$omsetp=0;
				$omsetdealerp=0;
				foreach ($p as $row16):
					     $omsetp= $omsetp + $row16->inttotal_omset;
						 
				endforeach;	
				foreach ($pDealer as $row31):
					     $omsetdealerp= $omsetdealerp + $row31->netDealer;
				endforeach;	 
				?>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>Point</td>
            <td align="center">0</td>
            <td align="center">0</td>
            <td align="center"><?php echo (empty($omsetp))?'0':number_format($omsetp)?></td>
            <td align="center"><?php echo (empty($omsetdealerp))?'0':number_format($omsetdealerp)?></td>
            <td align="center"><?php echo (empty($omsetdealerp))?'0':number_format(($omsetdealerp) * 5/100)?></td>
            <td align="center"><?php echo (empty($omsetdealerp))?'0':number_format(($omsetdealerp * 5/100)*5/100)?></td>
            <td align="center"><?php 
					$pD=0;
					$har_p=0;
					if(!empty($omsetdealerp)){
						$pD = $omsetdealerp;
						$har_p = (($omsetdealerp) * 5/100) - (($omsetdealerp* 5/100) * 5/100);
						echo (empty($har_p))?'0':number_format($har_p);
					}
					?></td>
          </tr>
	  <?php 
				$omsetm50=0;
				$omsetdealerm50=0;
				foreach ($m50 as $row17):
					     $omsetm50= $omsetm50 + $row17->inttotal_omset;
						 
				endforeach;	
				foreach ($m50Dealer as $row18):
					     $omsetdealerm50= $omsetdealerm50 + $row18->netDealer;
				endforeach;	 
				?>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>Metal 50%</td>
            <td align="center">0</td>
            <td align="center">0</td>
            <td align="center"><?php echo (empty($omsetm50))?'0':number_format($omsetm50)?></td>
            <td align="center"><?php echo (empty($omsetdealerm50))?'0':number_format($omsetdealerm50)?></td>
            <td align="center"><?php echo (empty($omsetdealerm50))?'0':number_format(($omsetdealerm50) * 2.5/100)?></td>
            <td align="center"><?php echo (empty($omsetdealerm50))?'0':number_format(($omsetdealerm50 * 2.5/100)*5/100)?></td>
            <td align="center"><?php 
					$m50D=0;
					$har_m50=0;
					if(!empty($omsetdealerm50)){
						$m50D = $omsetdealerm50;
						$har_m50 = (($omsetdealerm50) * 2.5/100) - (($omsetdealerm50* 2.5/100) * 5/100);
						echo (empty($har_m50))?'0':number_format($har_m50);
					}
					?></td>
          </tr>
          <tr class="detail">
            <td colspan="6">TOTAL FEE STOCKIST</td>
            <td align="center">&nbsp;</td>
            <td align="center"><?php echo number_format($regD + $hutD + $calD + $tinD + $ifiD + $ifoD + $netD + $spD + $pD + $m50D)?></td>
            <td align="center"><?php echo number_format(($regD * 5 / 100) + ($hutD * 5 / 100) + ($calD * 5/ 100) + ($tinD * 5/ 100)+ ($ifiD * 5/ 100)+ ($ifoD * 5/ 100)+ ($netD * 5/ 100) + ($spD * 5/ 100) + ($pD * 5/ 100) + ($m50D * 2.5/ 100))?></td>
            <td align="center"><?php echo number_format((($regD * 5/100) * 5/100) + (($hutD * 5/100)*5/100) + (($calD * 5/100) * 5/ 100) + (($tinD * 5/100 )* 5/ 100)+ (($ifiD * 5/100) * 5/ 100)+ (($ifoD * 5/100) * 5/ 100)+ (($netD * 5/100) * 5/ 100) + (($spD * 5/100) * 5/ 100) + (($pD * 5/100) * 5/ 100) + (($m50D * 2.5/100) * 5/ 100));?></td>
            <td align="center"><?php echo number_format($har_hut + $har_reg + $har_cal + $har_tin + $har_ifi+ $har_ifo+ $har_net + $har_sp + $har_p + $har_m50)?></td>
          </tr>
        </table></td>
    </tr>
	<tr><td>&nbsp;</td></tr>
	<tr><td colspan="3"><hr></td></tr>
	<tr><td>&nbsp;</td></tr>
    <tr><td colspan="3"><hr></td></tr>
                <tr>
                	<td align="center"><table width="800" align="center" class="detail">
                        <tr class="detail2">
                          <td width="229" colspan="4" align="center">DIBUAT OLEH</td>
                          <td width="229" colspan="4" align="center">DIPERIKSA OLEH</td>
                          <td width="229" colspan="4" align="center">DITERIMA OLEH</td>
                        </tr>
                        <tr>
                          <td width="229" colspan="4" align="right">&nbsp;</td>
                          <td width="229" colspan="4" align="right">&nbsp;</td>
                          <td width="229" colspan="4" align="right">&nbsp;</td>
                        </tr>
                        <tr>
                          <td width="229" colspan="4" align="right">&nbsp;</td>
                          <td width="229" colspan="4" align="right">&nbsp;</td>
                          <td width="229" colspan="4" align="right">&nbsp;</td>
                        </tr>
                        <tr>
                          <td width="230" colspan="4" align="center">(....................)</td>
                          <td width="230" colspan="4" align="center">(....................)</td>
                          <td width="230" colspan="4" align="center">(....................)</td>
                        </tr>
                      </table></td>
  </tr>
</table>
</body>
</html>